Locking Problems

If you are running an INSERT/UPDATE/DELETE or a DDL statement (like TRUNCATE, or refreshing a Materialized View), the problem may not lie with your SQL. You may be locked out by another session or by the lack of a specific resource.

Whilst the SQL is running, run st.sql in another session and check the Wait Event. If the Wait Event mentions Lock, Latch, or Enq (enqueues), then your SQL is probably doing nothing but waiting. Show the Wait Event to your DBA and take it from there.

There are some locking problems that you may be able to solve yourself. If the Wait Event indicates Latch or Enqueue problems, then you almost certainly need help from the DBA. However Locks are pretty easy to diagnose.

If you run waiters.sql, it will list all of the sessions waiting on locks, the OS user id of the waiter, the table they are waiting for, and the session/name of the holder of the lock. If waiters.sql shows that your session is waiting on another, use the information provided on the holder and find out what they are doing and when they will be finished. You'd be surpised how many times you actually lock yourself out with another session.


©Copyright 2003